import {fromJS} from "immutable";
import {change_car_status_data, save_car_message_data, save_car_warning_data} from "./actionCreator";


/**
 * batteryBurglarEarlyAlarmCount: 0
 burglarEarlyAlarmCount: 0
 carAmpereAlarmCount: 0
 carAngleAlarmCount: 0
 carBurglarEarlyAlarmCount: 0
 carChargingStatusCount: 4
 carExceptionOfflineAlarmCount: 0
 carOffLineCount: 114
 carTemperatureAlarmCount: 0
 carTotalCount: 157
 carVpvAlarmCount:

 carTotalCount:0,      //总数量
 carOffLineCount:0,    //离线数量
 carVpvAlarmCount:0,     //电压异常
 carAmpereAlarmCount:0,   //电流异常
 carTemperatureAlarmCount:0,   //温度异常
 burglarEarlyAlarmCount:0,  //防盗预警
 * @type {any}
 */

const defaultStatus =fromJS({
    carStatisticsData:{
        carTotalCount:0,      //总数量
        carOffLineCount:0,    //离线数量
        carVpvAlarmCount:0,     //电压异常
        carAmpereAlarmCount:0,   //电流异常
        carTemperatureAlarmCount:0,   //温度异常
        burglarEarlyAlarmCount:0,  //防盗预警
    },
    carsMessageArray:[],
    carsWarningArray:[],
    showWindowPosition:-1, //当前展示的window 对象

});


export default (status = defaultStatus,action)  =>{

    switch (action.type) {
        case change_car_status_data:

            return status.set("carStatisticsData",fromJS(action.data));
        case save_car_message_data:

            return  status.set("carsMessageArray",status.get("carsMessageArray").concat(fromJS(action.data)));

        case save_car_warning_data:

            return  status.set("carsWarningArray",status.get("carsWarningArray").concat(fromJS(action.data)));

        default:
            return status;
    }
}